package com.sun.hunk.struts.form;

import com.sun.hunk.hibernate.domain.Invoice;
import com.sun.hunk.hibernate.domain.impl.DomainFactory;
import com.sun.hunk.struts.HunkActionForm;
import com.sun.hunk.util.DateUtil;
import java.text.ParseException;

/**
 *
 * @author sunil
 */
public class InvoiceForm extends HunkActionForm {

    Invoice invoice;

    public InvoiceForm() {
        invoice = DomainFactory.getInvoice();
    }

    public Invoice getInvoice() {
        return invoice;
    }

    public void setInvoice(Invoice invoice) {
        this.invoice = invoice;
    }

    public void setDateFormatted(String date) throws ParseException {
        this.invoice.setDate(DateUtil.parseToDate(date, DateUtil.Format.MM_DD_YYYY));
    }

    public String getDateFormatted() throws ParseException {
        return DateUtil.formatToString(this.invoice.getDate(), DateUtil.Format.MM_DD_YYYY);
    }

    public void setOrderDateFormatted(String date) throws ParseException {
        this.invoice.setOrderDate(DateUtil.parseToDate(date, DateUtil.Format.MM_DD_YYYY));
    }

    public String getOrderDateFormatted() throws ParseException {
        return DateUtil.formatToString(this.invoice.getOrderDate(), DateUtil.Format.MM_DD_YYYY);
    }
}
